package com.lanou.musicbox.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lanou.musicbox.R;
import com.lanou.musicbox.adapter.NetworkMusicFragmentAdapter;
import com.lanou.musicbox.base.BaseFragment;

/**
 * Created by dllo on 15/10/24.
 */
public class EnterTheSeekMusicFragment extends BaseFragment {
    private TabLayout mTabLayout;
    private ViewPager mViewPager;
    private View v;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        v = inflater.inflate(R.layout.enterthe_seekmusic,null);
        initData();
        return v;
    }

    private void initData() {

        mTabLayout = (TabLayout) v.findViewById(R.id.enterthe_seekmusic_tabLayout);
        mViewPager = (ViewPager) v.findViewById(R.id.enterthe_seekmusic_viewPage);
        //如果是 fragment 的话,getChildFragmentManager()
        NetworkMusicFragmentAdapter adapter = new NetworkMusicFragmentAdapter(getChildFragmentManager());
        //设置充满
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
        mViewPager.setAdapter(adapter);
        //必须在 setAdapter()后调用
        mTabLayout.setupWithViewPager(mViewPager);
        mTabLayout.setTabsFromPagerAdapter(adapter);
        //0xff0088ff 0xff 代表透明度(0-255),0088ff 代表颜色
        mTabLayout.setSelectedTabIndicatorColor(0xff5F83E7);

    }
}
